package com.cjl.auth.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjl.anno.OperLog;
import com.cjl.auth.service.SysOperLogService;
import com.cjl.commons.result.Result;
import com.cjl.commons.utils.MD5;
import com.cjl.model.system.SysOperLog;
import com.cjl.model.system.SysUser;
import com.cjl.vo.system.SysOperLogQueryVo;
import com.cjl.vo.system.SysUserQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 操作日志记录 前端控制器
 * </p>
 *
 * @author cjl
 * @since 2023-03-20
 */
@Api(tags = "操作日志管理接口")
@RestController
@RequestMapping("/admin/system/sysOperLog")
public class SysOperLogController {

    @Autowired
    private SysOperLogService sysOperLogService;

    @ApiOperation("操作日志条件分页查询")
    @GetMapping("{page}/{limit}")
    @OperLog(businessType = "SELECT", title = "日志管理")
    public Result index(@PathVariable("page") Long page,
                        @PathVariable("limit") Long limit,
                        SysOperLogQueryVo sysOperLogQueryVo){
        Page<SysOperLog> pageParam = new Page<>(page, limit);
        IPage<SysOperLog> pageModel = sysOperLogService.queryOperLog(sysOperLogQueryVo, pageParam);
        return Result.ok(pageModel);
    }

    @ApiOperation(value = "获取操作日志")
    @GetMapping("get/{id}")
    @OperLog(businessType = "SELECT", title = "日志管理")
    public Result get(@PathVariable Long id) {
        SysOperLog sysOperLog = sysOperLogService.getById(id);
        return Result.ok(sysOperLog);
    }
}

